package com.wgy.blog.controller;

import com.wgy.blog.common.Result;
import com.wgy.blog.pojo.Label;
import com.wgy.blog.pojo.PageQuery;
import com.wgy.blog.service.LabelService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/label")
@RestController
public class LabelController {

    @Resource
    private LabelService labelService;


    @PostMapping("/add")
    public Result<Integer> add(@RequestBody Label label) {
        return labelService.add(label);
    }


    @PutMapping("update")
    public Result update(@RequestBody Label label) {
        Result<Integer> update = labelService.update(label);
        return update;
    }


    @PostMapping("del")
    public Result delete(@RequestBody Label label) {
        Result<Integer> delete = labelService.delete(label.getLabelId().longValue());
        return delete;
    }


    @GetMapping("findAll")
    public Result<List<Label>> findAll(PageQuery pageQuery) {
        Result<List<Label>> all = labelService.findAll(pageQuery);
        return all;
    }

    @GetMapping("find")
    public Result<List<Label>> find() {
        Result<List<Label>> all = labelService.find();
        return all;
    }
}
